home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / misc1 / iv26_w30.zip / INTERVIE / TEXTEDIT.H < prev    next >
C/C++ Source or Header  |  1980-01-03  |  3KB  |  102 lines

  1. /*
  2.  * Copyright (c) 1987, 1988, 1989 Stanford University
  3.  *
  4.  * Permission to use, copy, modify, distribute, and sell this software and its
  5.  * documentation for any purpose is hereby granted without fee, provided
  6.  * that the above copyright notice appear in all copies and that both that
  7.  * copyright notice and this permission notice appear in supporting
  8.  * documentation, and that the name of Stanford not be used in advertising or
  9.  * publicity pertaining to distribution of the software without specific,
  10.  * written prior permission.  Stanford makes no representations about
  11.  * the suitability of this software for any purpose.  It is provided "as is"
  12.  * without express or implied warranty.
  13.  *
  14.  * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  15.  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
  16.  * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  17.  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  18.  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  19.  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
  20.  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  21.  */
  22.  
  23. /*
  24.  * TextEditor - basic interactive editor for mulit-line text
  25.  */
  26.  
  27. #ifndef texteditor_h
  28. #define texteditor_h
  29.  
  30. #include <InterViews/interactor.h>
  31.  
  32. class TextDisplay;
  33. class TextBuffer;
  34.  
  35. class TextEditor : public Interactor {
  36. public:
  37.     TextEditor(int rows, int cols, int tabsize, int highlight);
  38.     TextEditor(const char* name, int r, int c, int t, int h);
  39.     virtual ~TextEditor();
  40.  
  41.     void Edit(TextBuffer*, int index = 0);
  42.  
  43.     int Dot();
  44.     int Mark();
  45.  
  46.     void InsertText(const char*, int);
  47.     void DeleteText(int);
  48.     void DeleteSelection();
  49.  
  50.     void BackwardCharacter(int = 1),    ForwardCharacter(int = 1);
  51.     void BackwardLine(int = 1),         ForwardLine(int = 1);
  52.     void BackwardWord(int = 1),         ForwardWord(int = 1);
  53.     void BackwardPage(int = 1),         ForwardPage(int = 1);
  54.  
  55.     void BeginningOfLine(),             EndOfLine();
  56.     void BeginningOfWord(),             EndOfWord();
  57.     void BeginningOfSelection(),        EndOfSelection();
  58.     void BeginningOfText(),             EndOfText();
  59.  
  60.     void SetScrollAlignment(Alignment);
  61.     Alignment GetScrollAlignment();
  62.  
  63.     void ScrollToSelection(boolean always = false);
  64.     void ScrollToView(Coord x, Coord y);
  65.     void ScrollBy(Coord dx, Coord dy);
  66.     void GrabScroll(Event&);
  67.     void RateScroll(Event&);
  68.     virtual void Adjust(Perspective&);
  69.  
  70.     void Select(int dot);
  71.     void SelectMore(int mark);
  72.     void SelectAll();
  73.     void Select(int dot, int mark);
  74.  
  75.     int Locate(Coord x, Coord y);
  76. protected:
  77.     virtual void Reconfig();
  78.     virtual void Redraw(Coord, Coord, Coord, Coord);
  79.     virtual void Resize();
  80.  
  81.     TextBuffer* text;
  82.     TextDisplay* display;
  83. private:
  84.     void ScrollTo(int x, int y);
  85.     void Init(int r, int c, int t, int h);
  86.  
  87.     int dot, mark;
  88.     int tabsize;
  89.     int lineheight;
  90.     int highlight;
  91.     int shaperows;
  92.     int shapecolumns;
  93.     Alignment scrollalign;
  94. };
  95.  
  96. inline int TextEditor::Dot () { return dot; }
  97. inline int TextEditor::Mark () { return mark; }
  98. inline void TextEditor::SetScrollAlignment (Alignment a) { scrollalign = a; }
  99. inline Alignment TextEditor::GetScrollAlignment() { return scrollalign; }
  100.  
  101. #endif
  102.